import { defHttp } from '@/utils/http/axios'

enum Api {
  DictList = '/dict/list',
  DictItemPageList = '/dictItem/page/list',
  AddorUpdateDict = '/dict/addOrUpdate',
  AddorUpdateDictItem = '/dictItem/addOrUpdate',
  DeleteDict = '/dict/delete',
  DeleteDictItem = '/dictItem/delete',
  StartOrStopItem = '/dictItem/startOrStop',
  ItemCollection = '/dictItem/itemCollection',
  DICTITEMLIST = '/dictItem/list',
  GET_DICT_LIST_BY_CODE = '/dictItem/getByDictCode/',
  GET_DICT_LIST_BY_CODE_AND_NAME = '/dictItem/getByDictCode',
  GETEnergyPriceType = '/energyPrice/getEnergyPriceType',
}

export const getDictList = () => defHttp.get({ url: Api.DictList })
export const getDictListByCode = (params) => defHttp.get({ url: Api.GET_DICT_LIST_BY_CODE, params })
export const getEnergyPriceType = () => defHttp.get({ url: Api.GETEnergyPriceType })
export const postDictItemPageList = (data) => defHttp.post({ url: Api.DictItemPageList, data })
export const postDictItemList = (data) => defHttp.post({ url: Api.DICTITEMLIST, data })
export const addorUpdateDict = (data) => defHttp.post({ url: Api.AddorUpdateDict, data })
export const addorUpdateDictItem = (data) => defHttp.post({ url: Api.AddorUpdateDictItem, data })
export const deleteDict = (dictId) => defHttp.get({ url: Api.DeleteDict, params: { dictId } })
export const deleteDictItem = (itemId) =>
  defHttp.get({ url: Api.DeleteDictItem, params: { itemId } })
export const startOrStopItem = (data) => defHttp.post({ url: Api.StartOrStopItem, data })
export const itemCollectionDict = () => defHttp.get({ url: Api.ItemCollection })
export const getDictListByCodeAndName = ({ code, itemName }) =>
  defHttp.get({ url: `${Api.GET_DICT_LIST_BY_CODE_AND_NAME}/${code}/${itemName}` })
